Special thanks to
Jason Aunkst
for this script.